<?php

$table_rank = array(
	'God of War' =>            50000000,
	'Legendary Force***' => 	 43000000,
	'Legendary Force**' =>	   37000000,
	'Legendary Force*' =>      31500000,
	'Legendary Force' =>       26500000,
	'World Class Force***' =>  22000000,
	'World Class Force**' =>   18000000,
	'World Class Force*' =>    14500000,
	'World Class Force' =>     11500000,
	'National Force***' =>      9000000,
	'National Force**' =>       7000000,
	'National Force*' =>        5800000,
	'National Force' =>         4900000,
	'Supreme Marshal***' =>     4150000,
	'Supreme Marshal**' =>      3500000,
	'Supreme Marshal*' =>       3000000,
	'Supreme Marshal' =>        2550000,
	'Field Marshal***' =>       2185000,
	'Field Marshal**' =>        1875000,
	'Field Marshal*' =>         1600000,
	'Field Marshal' =>          1350000,
	'General***' =>             1140000,
	'General**' =>               950000,
	'General*' =>                800000,
	'General' =>                 660000,
	'Colonel***' =>              540000,
	'Colonel**' =>               435000,
	'Colonel*' =>                355000,
	'Colonel' =>                 285000,
	'Lt Colonel***' =>           225000,
	'Lt Colonel**' =>            180000,
	'Lt Colonel*' =>             140000,
	'Lt Colonel' =>              110000,
	'Commander***' =>             85000,
	'Commander**' =>              67000,
	'Commander*' =>               52000,
	'Commander' =>                40000,
	'Major***' =>                 31000,
	'Major**' =>                  25000,
	'Major*' =>                   20000,
	'Major' =>                    15500,
	'Captain***' =>               12000,
	'Captain**' =>                 9000,
	'Captain*' =>                  6500,
	'Captain' =>                   5000,
	'Lieutenant***' =>             3750,
	'Lieutenant**' =>              3000,
	'Lieutenant*' =>               2350,
	'Lieutenant' =>                1850,
	'Sergeant***' =>               1400,
	'Sergeant**' =>                1000,
	'Sergeant*' =>                  800,
	'Sergeant' =>                   600,
	'Corporal***' =>                450,
	'Corporal**' =>                 350,
	'Corporal*' =>                  250,
	'Corporal' =>                   150,
	'Private***' =>                 100,
	'Private**' =>                   60,
	'Private*' =>                    30,
	'Private' =>                     10,
	'Recruit' =>                      0
);

/*
return value:
a[0] = rank level
a[1] = rank name
a[2] = percentage to next level
*/
function getRank($points)
{
	global $table_rank;

	reset($table_rank);
	$i = count($table_rank);
	$result = array();
	
	while ( ($level = current($table_rank)) !== FALSE ) {
		if ($points >= $level) {
			$rank_name = key($table_rank);
			$percent = ($points - $level) * 100 / (prev($table_rank) - $level);
			$result[] = $i;
			$result[] = $rank_name;
			$result[] = $percent;
			break;
		} else {
			--$i;
			next($table_rank);
		}
	}

	return $result;
}

?>